package org.example.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.common.Result;
import org.example.model.request.SleepRecordRequest;
import org.example.model.response.SleepRecordVO;
import org.example.service.SleepRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sleep/report/record")
@Tag(name = "睡眠报告记录")
public class SleepReportRecordController {

    @Autowired
    private SleepRecordService sleepRecordService;

    @PostMapping("/upload")
    @Operation(summary = "用户上传睡眠记录")
    public Result<String> uploadSleepRecord(@RequestBody SleepRecordRequest sleepRecordRequest) {
        return Result.success(sleepRecordService.uploadSleep(sleepRecordRequest));
    }

    @GetMapping("/nowWeek")
    @Operation(summary = "获取本周睡眠报告")
    public Result<List<SleepRecordVO>> getNowWeekSleepReport(@RequestParam("moreFlag") Boolean moreFlag) {
        return Result.success(sleepRecordService.getNowWeekSleepReport(moreFlag));
    }
}
